<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserAccountRecordTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_account_record', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id',false)->default(0)->index()->comment('用户id');
            $table->string('type', 10)->default('point')->index()->comment('日志类型 search=搜索次数 balance=余额');
            $table->decimal('amount',10,2)->default(0)->comment('变化数量');
            $table->decimal('current',10,2)->default(0)->comment('变化前数量');
            $table->string('text')->nullable()->comment('记录文本信息');
            $table->string('recordable_type',120)->nullable()->comment('关联数据类型');
            $table->unsignedBigInteger('recordable_id',false)->default(0)->comment('关联数据id');
            $table->timestamps();
            $table->engine="InnoDb";
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_account_record');
    }
}
